#include "DayRecord.h"
#include "ui_DayRecord.h"


DayRecord::DayRecord(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DayRecord)
{
    ui->setupUi(this);

    this->setWindowFlags(Qt::FramelessWindowHint | this->windowFlags());

    dbSupport = new DRDBSupport(this);

    splitter = new QSplitter(this);
    leftWindow = new DRWidgetLeft;
    rightWindow = new DRWidgetRight;

    splitter->addWidget(leftWindow);
    splitter->addWidget(rightWindow);
    splitter->setLineWidth(1);

    this->setCentralWidget(splitter);

    connect(this->rightWindow, SIGNAL(onMove(int,int)), this, SLOT(onMove(int,int)));
    connect(this->rightWindow, SIGNAL(onClose()), this, SLOT(close()));
    connect(this->rightWindow, SIGNAL(onMaximun(bool)), this, SLOT(onMaximum(bool)));
    connect(this->rightWindow, SIGNAL(onMinimum()), this, SLOT(onMinimum()));
}

DayRecord::~DayRecord()
{
    delete ui;
}

void DayRecord::onMove(int x, int y)
{
    this->move(this->x() + x, this->y() + y);
}

void DayRecord::onMaximum(bool current)
{
    if (current)
    {
        this->showNormal();
    }
    else
    {
#ifdef Q_OS_MAC
        this->showFullScreen();
#else
        this->showMaximized();
#endif

        resize(QApplication::desktop()->availableGeometry().size());
    }
}

void DayRecord::onMinimum()
{
    this->showMinimized();
}


void DayRecord::onSearchGroup(QString)
{

}

void DayRecord::onSearchRecord(QString)
{

}

void DayRecord::onDeleteGroup(int)
{

}

void DayRecord::onDeleteRecord(int)
{

}

void DayRecord::onAddRecord(int groupIndex)
{

}
